Repository navigation
Match the Content-Type header name case-insensitively - #3725
Merged
velo merged 1 commit intoNov 30, 2026
Merged
Conversation
Header names are case-insensitive, but two places that special-case
Content-Type compared the name with equals("Content-Type"):
* RequestTemplate replaces Content-Type instead of appending to it, so
a request ends up with a single type (OpenFeign#1219). Setting it as
`content-type`, e.g. from a RequestInterceptor on a method annotated
with `Content-Type: application/json`, appended instead, and the
request went out with two Content-Type headers.
* GoogleHttpClient skips Content-Type when copying headers, because
ByteArrayContent already sends it (OpenFeign#1737). A `content-type` header was
copied as well, so it was sent twice. When the request's header map
is case-sensitive (Request.create with a HashMap), the body was also
typed application/octet-stream next to the caller's value.
Both checks now use equalsIgnoreCase.
Signed-off-by: Sparshal Kothari <41056517+spor3006@users.noreply.github.com>
velo
approved these changes
Nov 30, 2026
velo
approved these changes
Nov 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Header names are case-insensitive, but the two places that treat Content-Type specially compare the name with
equals("Content-Type").RequestTemplate replaces Content-Type instead of appending to it, so a request carries a single type (#1219). When the header is set as
content-type, for example from a RequestInterceptor on a method annotated withContent-Type: application/json, it is appended instead, and DefaultClient sends two Content-Type headers.GoogleHttpClient skips Content-Type when it copies headers, because ByteArrayContent already sends it (#1737). A
content-typeheader was copied as well, so it went out twice. If the request was built with a case-sensitive header map (Request.create with a HashMap), the body was also typed application/octet-stream next to the caller's value.Both checks now use equalsIgnoreCase, and GoogleHttpClient looks the body type up the same way instead of
headers().get("Content-Type"). Nothing changes for the canonical spelling.Tests: RequestTemplateTest covers three spellings, FeignBuilderTest checks the interceptor case end to end against MockWebServer, and GoogleHttpClientTest covers both the duplicate header and the case-sensitive map. All of them failed before the change.
mvn -Pdev verifypasses for core, googlehttpclient, okhttp, hc5, httpclient, jaxrs2 and spring.